import SwiftUI

struct ModelConfigView: View {
    @Binding var isPresented: Bool
    @State private var providers = ModelProvider.providers
    
    var body: some View {
        VStack(spacing: 0) {
            // 标题栏
            HStack {
                Text("模型配置")
                    .font(.title3)
                    .fontWeight(.bold)
                    .padding()
                
                Spacer()
                
                Button(action: {
                    withAnimation {
                        isPresented = false
                    }
                }) {
                    Image(systemName: "xmark.circle.fill")
                        .foregroundColor(.gray)
                        .font(.title3)
                        .padding()
                }
            }
            .background(Color(red: 0.97, green: 0.97, blue: 0.97))
            .overlay(
                Rectangle()
                    .frame(height: 1)
                    .foregroundColor(Color.gray.opacity(0.3)),
                alignment: .bottom
            )
            
            // 模型列表
            ScrollView {
                VStack(spacing: 0) {
                    ForEach(providers) { provider in
                        ProviderRow(provider: provider)
                            .padding(.vertical, 12)
                            .padding(.horizontal, 12)
                        
                        if provider.id != providers.last?.id {
                            Divider()
                                .padding(.horizontal, 12)
                        }
                    }
                }
                .padding(.vertical)
            }
        }
        .frame(width: 650, height: 500)
        .background(Color.white)
        .cornerRadius(12)
        .shadow(radius: 15)
        .contentShape(Rectangle())
        .onTapGesture {
            // 阻止点击事件传递到背景
        }
    }
} 